<?php
require_once('../config/auth.php');
require_once('service.cl.php');
$__CURRENT_PAGE__ = 'service';
$__TITLE__ = "liste de modification des services";
$service = new Service();
$departementId = empty($_GET['departement_id']) ? 0 : $_GET['departement_id'];
$services = $service->getServiceBydepartementId($departementId); 
$departements = $service->getDepartement()->getAllDepartements();
require_once(dirname(__FILE__).'/../config/head.php'); ?>
<body>
<?php require_once(dirname(__FILE__).'/../config/menu.php'); ?>
<div class="container serviceList">
<a class="btn btn-success pull-right" href="form.php">Ajouter un service</a><br>
    <select name="departement_id" id="departement_id">
          <option value="">Selectionner un departement</option>
          <?php foreach($departements as $depart): ?>
            <option  <?php echo ($service->getDepartementId() == $depart->id)  ? 'selected="selected"' : '' ?>
              value="<?php echo $depart->id?>"><?php echo $depart->name ?></option>   
          <?php endforeach ?>
   </select>
   <br>  <br>  <br>
	<table class="table table-striped" width="500" aling="center">
		<thead>
			<th>Nom</th><th>Abréviation</th>
		</thead>
        <tbody>
        	<?php foreach($services as $serv):?>
                <tr>
                	<td><?php echo $serv->name?></td><td><?php echo $serv->abreviation?></td><td> <?php echo "<a href='form.php?id=".$serv->id."'>modifier</a>" ?>
                </td>
                </tr>
            <?php endforeach ?>
        </tbody>
	</table>
</div>
</body>
